package jjn.acwing.java_basic;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/9/3 22:28
 */
public class Acwing754 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            if (n == 0) break;
            int[][] arr = new int[n][n];
            for (int j = 0; j < n; j++) {
                for (int k = j, l = 1; k < n; k++, l++) {
                    arr[j][k] = l;
                    arr[k][j] = l;
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    System.out.printf("%d ", arr[i][j]);
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}
